<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>考试系统科目管理界面</title>
    <link rel="stylesheet" type="text/css" href="/admin/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/css/bootstrap-table.min.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/css/style.min.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/css/font-awesome.css"/>
    <link rel="stylesheet" href="/admin/layui/css/layui.css">

    <script src="/admin/js/jquery-3.3.1.min.js"></script>
    <script src="/admin/js/bootstrap.js"></script>
    <script src="/admin/js/bootstrap-table.js" type="text/javascript" charset="utf-8"></script>
    <script src="/admin/js/bootstrap-table-zh-CN.js"></script>
    <script src="/static/admin/layui/layui.js" charset="utf-8"></script>
    <script src="/admin/js/base.js" charset="utf-8"></script>

    <!-- 树 -->
    <link rel="stylesheet" href="/lib/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="/lib/zTree/js/jquery.ztree.core-3.5.js"></script>
    <script type="text/javascript" src="/lib/zTree/js/jquery.ztree.excheck-3.5.js"></script>
    <script type="text/javascript" src="/lib/zTree/js/jquery.ztree.exedit-3.5.js"></script>
    <script src="/admin/js/api.js" charset="utf-8"></script>
    <script src="/admin/js/common.js" charset="utf-8"></script>
    <script src="/admin/js/tree.js" charset="utf-8"></script>

    <style>
        .ztree li span[id^="treeDemo_"][id$="_span"] {
            width: auto;
            min-width: 140px;
        }

    </style>

</head>
<body>
<div class="rigthContent">
    <div class="col-sm-12">

        <!--字典树相关-->
        <div class="col-sm-5" style="border-right: 1px solid #CCCCCC;">
            <div class="tool_bar" id="first_tool_bar" style="padding: 8px 0 0px 4px;">
                <a href="javascript:;" class="btn btn-default btn-sm" onclick="addTree();">
                    <span class="icon  icon-plus-sign handle_ioc"></span>
                    添加
                </a>
                <a href="javascript:;" id="expandAllBtn" class="btn btn-default btn-sm">
                    <span class="icon icon-double-angle-down handle_ioc"></span>
                    展开
                </a>
                <a href="javascript:;" id="resetBtn" class="btn btn-default btn-sm">
                    <span class="icon icon-double-angle-up handle_ioc"></span>
                    收起
                </a>
            </div>
            <div class="pageContent" id="pageContent">
                <div class="manageeditdiv">
                    <ul id="treeDemo" class="ztree" style="-moz-user-select: none;">
                    </ul>
                </div>
            </div>
        </div>


        <!--字典详情相关-->
        <div class="col-sm-7">
            <div class="ibox float-e-margins">
                <div class="">
                    <div class=" search-top"  >
                        <form class="layui-form" action="" id="searchForm" style="margin-bottom: 0;">
                            <input type="hidden" id="dicId" name="dicId" value="">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">名称：</label>
                                    <div class="layui-input-inline">
                                        <input name="name" id="name" value="" class="form-control input-sm"
                                               aria-controls="editable" type="search">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">Code：</label>
                                    <div class="layui-input-inline">
                                        <input name="code" id="code" value="" class="form-control input-sm"
                                               aria-controls="editable" type="search">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <a href="javascript:;" class="btn btn-info btn-sm searchListener"><span
                                            class="icon icon-search handle_ioc"></span>搜索</a>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline tool_bar"  style="float: right">

                                    <a href="javascript:void(0);" class="btn btn-default btn-sm" onclick="windowloadList()">
                                        <span class="icon icon-refresh handle_ioc"></span>刷新
                                    </a>
                                    <a href="javascript:void(0);" class="btn btn-default btn-sm common-add" onclick="addDicDetail()">
                                        <span class="icon  icon-plus-sign handle_ioc "></span>添加
                                    </a>
                                    <a href="javascript:void(0);" class="btn btn-default btn-sm common-update"
                                       onclick="updateDicDetail()">
                                        <span class="icon icon-edit handle_ioc"></span>修改
                                    </a>
                                    <a href="javascript:void(0);" class="btn btn-default btn-sm common-delete"
                                       onclick="deleteDicDetail()">
                                        <span class="icon icon-remove-sign handle_ioc "></span>删除
                                    </a>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>

                <div class="content">
                    <div>
                        <table class="table" id="table_list" aria-describedby="editable_info"
                               style="table-layout:fixed"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    var currentSelectNode;

    //layui准备
    layuiReady(function () {
        _loading();
    });

    function zTreeBeforeClick(treeId, treeNode, clickFlag) {
        $("#dicId").val(treeNode.id);
        currentSelectNode = treeNode;
        initTableSearch();
    };

    /************************************************begin操作数据字典树****************************************/
    treeOption = {
        treeList: Api.base.dataDictionary.getDataDictionaryList,
        addChildren: Api.base.dataDictionary.addHtml,
        removeTree: Api.base.dataDictionary.deleteDataDictionary,
        updateOrder: Api.base.dataDictionary.updateDataDictionaryOrder
    };

    /************************************************begin数据字典详情****************************************/
    conlums = [
        {
            field: 'check',
            checkbox: true,
            width: '0',
            class: 'tableCheckStatus',
        }, {
            field: 'Number', class: 'tableNumber',//可不加
            title: '序号',
            align: 'center',
            valign: 'top',
            width: '30px',
            formatter: function (value, row, index) {
                return tableNumber(index);
            }
        }, {
            field: 'name',
            title: '名称',
            width: '220',
            align: 'center',
            align: 'center',
            valign: 'middle',
            class: 'over_hidden',
        }, {
            field: 'code',
            title: 'Code码',
            align: 'center',
            width: '120'
        }, {
            field: 'createDate',
            title: '创建时间',
            width: '80',
            align: 'center',
            valign: 'middle',
            class: 'over_hidden',
            formatter: function (value, row, index) {
                return dateFormat(value, "yyyy-MM-dd");
            }
        }
    ];

    /************************************************begin操作数据字典详情****************************************/
    //刷新数据列表 搜索数据字典详情
    function initTableSearch() {
        init_table_search();
    }

    //初始化数据字典详情表格
    $(function () {
        init_table(Url.creatUrl(Api.dataDictionaryDetail.getDataDictionaryDetailList, {}), conlums);
    });

    //添加详情信息
    function addDicDetail() {
        var url = '';
        if (currentSelectNode) {
            url = Url.creatUrl(Api.dataDictionaryDetail.addHtml, {pid: currentSelectNode.id});
            popup(url, "添加字典详情", "650px", "500px");
        } else {
            layerMessage("请选择父级！")
        }
    }

    //修改详情信息
    function updateDicDetail() {
        var row = select_one_row();
        if (row) {
            popup(Url.creatUrl(Api.dataDictionaryDetail.addHtml, {
                pid: currentSelectNode.id,
                id: row.id
            }), '修改字典详情', '650px', '500px');
        } else {
            return;
        }
    }

    //删除详情信息
    function deleteDicDetail() {
        var row = select_one_row();
        if (row) {
            var id = row.id;
            deleteDicDetailInfo(id);
        } else {
            return;
        }
    }

    function deleteDicDetailInfo(id) {
        layer.confirm("删除后不可恢复,确认要删除吗？", {
            shade: 0.2,
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            This.jqueryAjax(Api.dataDictionaryDetail.deleteDataDictionaryDetail, {id: id}, 'json', function (data) {
                if (data.status == 1) {
                    layerMessage('删除成功！');
                    initTableSearch();
                } else {
                    layerMessage('删除成功！', 2);
                    layer.close(index);
                }
            })
        });
    }


</script>
</html>